package cn.tedu.charging.order.controller;

import cn.tedu.charging.common.pojo.jsonResult.JsonResult;
import cn.tedu.charging.order.pojo.param.OrderAddParam;
import cn.tedu.charging.order.service.OrderService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("order")
@Api(tags = "订单模块")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("create")
    public JsonResult createOrder(@RequestBody OrderAddParam orderAddParam){
        log.debug("创建订单-入参:{}",orderAddParam);//打印入参，确定前端传来的数据原始的值
        //打印入参，确定入参是否被修改
        log.debug("创建订单-orderService:入参:{}",orderAddParam);
        String orderNo=orderService.createOrder(orderAddParam);
        //打印入参，确定入参是否被修改，入参出参可以对应上
        log.debug("创建订单-orderService:入参:{},出参:{}",orderAddParam,orderNo);
        JsonResult<String> result = new JsonResult();
        result.setCode(2000);
        result.setMessage("创建订单成功");
        result.setData(orderNo);
        //打印入参，确定入参出参是否对应上，确认result的值
        log.debug("创建订单-入参:{},出参:{}",orderAddParam,result);
        return result;
    }
}
